home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 3207 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.9 KB

  1. Path: asmobj.larc.nasa.gov!jaapjl
  2. From: jaapjl@asmobj.larc.nasa.gov (Lee Jaap)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: What is '?' in C mean....?????
  5. Date: 26 Jan 1996 23:44:49 GMT
  6. Organization: probably not speaking for AS&M Inc
  7. Message-ID: <JAAPJL.96Jan26184450@asmobj.larc.nasa.gov>
  8. References: <4cgsa8$bm2@wumpus.cc.uow.edu.au> <4cvp4d$b6u@news.worldlinx.com>
  9.     <ALUN.CHAMPION.96Jan10101442@g7240065.bridge.bst.bls.com>
  10. Reply-To: J Lee Jaap <jaapjl@asmsun.larc.nasa.gov>
  11. NNTP-Posting-Host: asmobj.larc.nasa.gov
  12. In-reply-to: Alun.Champion@bridge.bst.bls.com's message of 10 Jan 1996 15:14:42 GMT
  13.  
  14. In article <ALUN.CHAMPION.96Jan10101442@g7240065.bridge.bst.bls.com> Alun.Champion@bridge.bst.bls.com (Alun Champion) writes:
  15. |>In article <4cvp4d$b6u@news.worldlinx.com> stupy@freenet.durham.org (Steve Tupy) writes:
  16. |>: PAOPENG THEERADECH (tp86@wumpus.cc.uow.edu.au) wrote:
  17. |>
  18. |>:: Hello to all.
  19. |>::     I got something here to ask you guys. I saw some symbol like "?" be
  20. |>:: used in some codes. I don't understand what does it mean. I tried to read some
  21. |>:: text books but I still cannot find the detail about "?". The codes that I saw 
  22. |>:: are;
  23. |>::         max = x>y ? x:y;
  24. |>::          
  25. |>::             and
  26. |>
  27. |>::         printf("%d", x>y ? x:y);
  28. |>
  29. |>: It tells you that an evaluation is about to happen. If x>y then max = x, if
  30. |>: x>y == 0 then max = y. The first value left of the colon is applied only if
  31. |>: it evaluates to 1, else the right side is applied.
  32. |>
  33. |>That should really be: The first value left of the colon is applied
  34. |>if the expression doesn't evaluate to 0, else the right side is applied.
  35. |>Any non-zero value will cause the left hand side to be evaluated, in C
  36. |>anything non-zero is true ;')
  37.  
  38. Any decent C book will describe the ternary operator or the
  39. conditional expression operator.
  40. --
  41. J Lee Jaap <JaapJL@ASMSun.LaRC.NASA.Gov> +1 804/865-7093
  42.       employed by, not necessarily speaking for,
  43.             AS&M Inc, Hampton VA 23666-1340
  44.